package config

import (
	"github.com/BurntSushi/toml"
	"log"
)

type Server struct {
	Addr string
	Port int
}

type Database struct {
	Path string
}

type Media struct {
	Roots []string
}

type Config struct {
	Server   Server
	Database Database
	Media    Media
}

func ParseToml(file string) *Config {
	var conf Config
	conf.Server.Addr = "127.0.0.1"
	conf.Server.Port = 3000
	conf.Database.Path = "./video.db"

	if _, err := toml.DecodeFile(file, &conf); err != nil {
		log.Fatal("decode TOML failed: ", err)
	}

	return &conf
}
